import java.io.BufferedReader;
import java.io.FileReader;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Random;
import java.util.StringTokenizer;

import utils.Facet;
import utils.Layer;
import utils.Ligne;
import utils.Vertex;

//test


public class TopmodReader2 {
	public ArrayList<Facet>FacetArray=new ArrayList<Facet>();


	
	public TopmodReader2() throws Exception{
		   //BufferedReader in = new BufferedReader(new FileReader("C:\\Documents and Settings\\Francesco\\Bureau\\PyTopMod2.223\\dodecahedron.obj"));
		   BufferedReader in = new BufferedReader(new FileReader("C:\\Documents and Settings\\moi\\Bureau\\PyTopMod2.223\\dodecahedron.obj"));
			
		   String ligne = in.readLine();
			
			
			while (ligne != null) {
				System.out.println("-->"+ligne);
				if(ligne.length()!=0){
				StringTokenizer st=new StringTokenizer(ligne);
				String nt=st.nextToken(); 
				if(nt.equals("v")){
				
					
						
					double x=Double.parseDouble(st.nextToken());
					double y=Double.parseDouble(st.nextToken()); 
					double z=Double.parseDouble(st.nextToken()); 
					Vertex v=new Vertex(x,y,z);
					System.out.println(v);
					
					}
				else{
					
				System.out.println("else");
				if(nt.equals("f")){
					int i0=0,i1=0,i2=0; 
			
						i0=Integer.parseInt(st.nextToken())-1; 
						i1=Integer.parseInt(st.nextToken())-1; 
						i2=Integer.parseInt(st.nextToken())-1; 
					
					Facet fc=new Facet(i0,i1,i2); 
					System.out.println(fc);
					FacetArray.add(fc);
				}
				
			}
				}
				System.out.println("done"); 
				ligne = in.readLine();
			}
			in.close();
			
		
	}
	public static void main(String[] args) throws Exception{
		TopmodReader2 hh=new TopmodReader2();
		
		PrintStream output=new PrintStream("outdodec.txt");
		
		
		//output.println("****************");
		output.println("mesh2{"); 
		output.println("vertex_vectors {"); 
		output.println(Vertex.dejaVU.size()+","); 
		for(Vertex v : Vertex.dejaVU)
			output.println(v+",");
		output.println("}"); 
		output.println("face_indices {"); 
		output.println(hh.FacetArray.size()+","); 
			
		for(Facet f:hh.FacetArray)
			output.println(f+",");
		output.println("}\n }");
		output.close(); 
	}

}
